{{- define "main" -}}

<article class="article article-project">

  {{ partial "page_header.html" . }}

  <div class="article-container">

    <div class="article-style">
      {{ .Content }}
    </div>

    {{ partial "page_footer" . }}

    <div class="project-related-pages content-widget-hr">
      {{ $page := . }}
      {{ $project := .File.ContentBaseName }}

      {{ $items := where (where site.RegularPages "Type" "post") ".Params.projects" "intersect" (slice $project) }}
      {{ $count := len $items }}
      {{ if ge $count 1 }}
        <h2>{{ (i18n "posts") }}</h2>
        {{ range $index, $item := $items }}
          {{ partial "functions/render_view" (dict "page" $ "item" . "view" (site.Params.projects.post_view | default "compact") "index" $index) }}
        {{end}}
      {{ end }}

      {{ $items := where (where site.RegularPages "Type" "publication") ".Params.projects" "intersect" (slice $project) }}
      {{ $pubs_len := len $items }}
      {{ if ge $pubs_len 1 }}
        <h2>{{ (i18n "publications") }}</h2>
        {{ range $index, $item := $items }}
          {{ partial "functions/render_view" (dict "page" $ "item" . "view" (site.Params.projects.publication_view | default "compact") "index" $index) }}
        {{end}}
      {{ end }}

      {{ $items := where (where site.RegularPages "Type" "event") ".Params.projects" "intersect" (slice $project) }}
      {{ $talks_len := len $items }}
      {{ if ge $talks_len 1 }}
        <h2>{{ (i18n "talks") }}</h2>
        {{ range $index, $item := $items }}
          {{ partial "functions/render_view" (dict "page" $ "item" . "view" (site.Params.projects.talk_view | default "compact") "index" $index) }}
        {{end}}
      {{ end }}
    </div>
  </div>
</article>
{{- end -}}
